import absunitPkg from './absunit.js'
import coorPkg from '../../struct/coord.js'

class DevGraphInfo extends absunitPkg.AbsStruct {
    constructor() {
        super();
        this.scalex = 1;
        this.scaley = 1;
        this.pos = new coorPkg.PointPos();
        this.connNodeIDs = "";
        this.x = 0;
        this.y = 0;
        this.exflag = false;//作为图符内子图元时有效，标识为外部导入文件中的模具
    }

    translate(tx,ty){
        if (this.pos){
            this.pos.offset(tx,ty);
        }
        this.x += tx;
        this.y += ty;
        this.scope_left += tx;
        this.scope_top += ty;
        this.scope_right += tx;
        this.scope_bottom += ty;
    }

    toJson() { 
        var jsonobj = {};
        super.commonPropToJson(jsonobj);
        jsonobj["scalex"] = this.scalex;
        jsonobj["scaley"] = this.scaley;
        jsonobj["x"] = this.x;
        jsonobj["y"] = this.y;
        jsonobj["connNodeIDs"] = this.connNodeIDs;
        jsonobj["exflag"] = this.exflag;
        return jsonobj;
    }
    fromJson(obj) { 
        super.commonPropFromJson(obj);
        this.connNodeIDs = obj["connNodeIDs"];
        this.x = obj["nx"];
        if (this.x == null){
            this.x = obj["x"];
        }
        this.y = obj["ny"];
        if (this.y == null){
            this.y = obj["y"];
        }
        this.pos.x = this.x;
        this.pos.y = this.y;
        this.disLabelContent = obj["disLabelContent"];

        this.scalex = obj["scalex"];
        if (this.scalex == null){
            this.scalex = 1;
        }
        this.scaley = obj["scaley"];
        if (this.scaley == null){
            this.scaley = 1;
        }
        this.exflag = obj["exflag"];
        if (this.exflag === undefined){
            this.exflag = false;
        }
    }
    cloneCopy() {
        var pNewInfo = new DevGraphInfo();
        super.cloneBaseProp(pNewInfo);
        pNewInfo.x = this.x;
        pNewInfo.y = this.y;
        pNewInfo.scalex = this.scalex;
        pNewInfo.scaley = this.scaley;
        pNewInfo.disLabelContent = this.disLabelContent;
        pNewInfo.connNodeIDs = this.connNodeIDs;
        pNewInfo.exflag = this.exflag;
        pNewInfo.setPos(this.getPos());
        return pNewInfo;
    }
}

export default { DevGraphInfo }